<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<head>
<%@ include file="/include/include.jsp" %>

	<script type="text/javascript">
		var ctx_ = "<%=request.getContextPath()%>";
		 
		function chooseRegion(form,id){
	
			if (id == "") {
				return;
			}
			var url =  ctx_ + '/warehouse/invetnroyrecord/region/' + id ;
			form.action=url;
			form.submit();
		}

		function chooseWarehouse(form,id ){
			if (id == ""){
				return ;
			}

			form.submit();
			
		}

		function search(warehouseId){
			//if ( $('timepart_').value == '') {
			//	return;
			//}
		//	var arrays = $('timepart_').value.split('-');
			if($('beginDate').value == ''){
				alert('请选择起始时间！');
				return;
			}
			if($('endDate').value == ''){
				alert('请选择结束时间！');
				return;
			}
		    var beginDate = $('beginDate').value;
		    
		    var endDate = $('endDate').value;
		    
		//    alert(beginDate+'   '+ endDate);
		    
			var url = ctx_ + '/warehouse/inventoryrecord/waresearch/'+warehouseId+'/view?beginDate='+beginDate+'&endDate='+endDate;
			window.location=url;
		}
		function changeValue(){
			var myAjax = new Ajax.Request(
					ctx+'/warehouse/inventoryrecord/gettimepart', // 请求的URL
					{
	                    method: 'post', // 使用GET方式发送HTTP请求
	                    onComplete: showResponse // 指定请求成功完成时需要执行的方法
	                }
	            );
		}
		function showResponse(request){
			//alert(request.responseText);

			var obj = $('timepart');
			var jsonDate= eval("("+request.responseText+")");
			for(var i = 0,len = jsonDate.length;i<len;i++){
					var date = jsonDate[i].date;
					var aa = date.split('-')[0]+'年'+date.split('-')[1]+'月';
					//alert(aa);
					obj.add(new Option(aa,date));
					//alert(date);
			}
						
		}
	</script>
</head>

<body>
		<%@ include file="/include/header.jsp" %>
			<%@ include file="/include/script.jsp" %>
		<%@ include file="/include/menu.jsp" %>
		<div id="mainContent">
		
			<h2><a href="${ctx}/${menu.url}">${menu.description}</a>&nbsp;-&nbsp;<a href="${ctx}/${empty currViewBarSubMenu_ ? submenu.url : currViewBarSubMenu_.url}">${empty currViewBarSubMenu_ ? submenu.description : currViewBarSubMenu_.description}</a></h2>
			<div class="tool-bar">
				
				<div title="${menu.description} - ${empty currViewBarSubMenu_ ? submenu.description : currViewBarSubMenu_.description} - 查询${empty currViewBarSubMenu_ ? submenu.description : currViewBarSubMenu_.description}"  href="${ctx}/warehouse/inventoryrecord/search/filter" class="modal-window modal-link">过滤查询</div>
				<div title="${menu.description} - ${empty currViewBarSubMenu_ ? submenu.description : currViewBarSubMenu_.description} - 查询${empty currViewBarSubMenu_ ? submenu.description : currViewBarSubMenu_.description}"  href="${ctx}/warehouse/inventoryrecord/list/toexport" class="modal-window modal-link">导出仓储产品</div>
			</div>
			<!-- 
			<form id="form1" action="${ctx}/warehouse/inventoryrecord/search/do" method="post"  style="margin: 0px;">
				<table cellspacing="0" cellpadding="0" align="left" >
					<tbody>
						<tr>
							<td width="60px">地区选择：</td>
							<td>
								<select name="myregion" dataType="Require" msg="未选定仓储" onchange="chooseRegion($('form1'),this.value);">
									<option value="" >请选择</option>
									<c:forEach var="region_" items="${regions}" varStatus="status">
											<option value="${region_.id}"  ${region_.id == region.id ? 'selected="selected"' : '' }>${region_.number} - ${region_.name }</option>
									</c:forEach>
								</select>
							</td>
							<td width="60px">仓储选择：</td>
							<td>
								<select name="eq.inventoryrecord.warehouse.code" onchange="search(this.value);">
									<option value="" selected="selected">请选择</option>
									<c:forEach var="warehouse" items="${warehouses}" varStatus="status">
											<option value="${warehouse.id}"  >${warehouse.code} - ${warehouse.name }</option>
									</c:forEach>
								</select>
							</td>
							<td width="80px" style="display: none">选择时间段：</td>
							<td>
								<select style="display: none" name="timepart_" id="timepart_">
									<c:forEach var="timepart" items="${timeparts}" varStatus="status">
											<option value="${timepart}"  >${fn:split(timepart,"-")[0]}年${fn:split(timepart,"-")[1]}月 </option>
									</c:forEach>
								</select>
							</td>
							<td>起始时间：</td>
							<td><input class="Wdate" id='beginDate' name="beginDate" type="text" onClick="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd'})" /></td>
							<td>结束时间: </td>
							<td><input class="Wdate" id='endDate' name="endDate" type="text" onClick="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd'})" /></td>
						</tr>
					</tbody>
				</table>
				<br />
				<br />
				 -->
				
			
				<table class="grid" cellspacing="0">
					<thead>
						<tr>
							<td>仓储编号</td>
							<td>仓储名称</td>
							<td>所在区域</td>
							<td>联系人</td>
							<td>联系地址 </td>
						</tr>
					</thead>
					<tbody>
						<c:forEach var="warehouse" items="${warehouses}" varStatus="status">
							
							<tr onmouseover="this.style.backgroundColor= '#A0CFEC'" onmouseout="this.style.backgroundColor= '#ffffff'" ${ inventory.inventoryWarningRecord != null ? 'class="warning" ' : ''}>
								<td>
									<a href="${ctx }/warehouse/inventoryrecord/search/filter/do/?eq.inventoryrecord.warehouse.code=${warehouse.code}">${warehouse.code}</a>	
								</td>
								<td>
									<a href="${ctx }/warehouse/inventoryrecord/search/filter/do/?eq.inventoryrecord.warehouse.code=${warehouse.code}">${warehouse.name}</a>	
								</td>
								<td>${warehouse.region.name}</td>
								<td>${warehouse.person}</td>
								<td>${warehouse.address}</td>
						</tr>
						</c:forEach>
					</tbody>
				</table>
				
			</form>
		</div>
	</body>	
